<?php

$p = \Drupal\shushengyuan\Schemas\ProductItemInfo::init(54, FALSE, [1]);
dpm($p['poster']);


$uid = 324;
$url = wx_mini_qr_create('shusy_team', 'storeApply_' . $uid, [
  'uid' => $uid,
  'type' => 'team',
]);
dpm(file_create_url($url));

$c = new \Drupal\shushengyuan\ShushengyuanServicesRetrieveController();
$r = $c->loadOrderLogistics(3580);
dpm($r);


for ($i = 3337; $i <= 3386; $i++) {
  $o = shusy_store_order_load($i);
  $o->status = 0;
  $o->save();
}

db_truncate('youji_profit')->execute();
db_truncate('youji_profit_revision')->execute();


$d = distribution_load(4);
if ($d instanceof \Drupal\distribution\Entity\Distribution) {
  $d->tid = 558;
  $d->save();
}

use Drupal\shushengyuan\Schemas\MyInnerTeam;

$uid = 324;
$query = db_select('shusy_team', 't');
$query->fields('t', ['id']);
$query->condition('status', 1);


$db_or = db_or();
$db_or->condition('market_1', $uid);
$db_or->condition('market_2', $uid);
$db_or->condition('company_1', $uid);
$db_or->condition('company_2', $uid);

$db_and = db_and();
$db_and->condition($db_or);

$query->condition($db_and);

$query->orderBy('id', 'DESC');
$result = $query->execute();
$list = [];
while ($row = $result->fetchAssoc()) {
  $list[] = MyInnerTeam::init($row['id']);
}
dpm($list);


points_to_uid(620, 'dev', 'income', 100000);


$es = shusy_gift_card_load_multiple(FALSE);
foreach ($es as $e) {
  if ($e instanceof \Drupal\shusy_gift_card\Entity\ShusyGiftCard) {
    $e->delete();
  }
}

$es = shusy_store_order_load_multiple(FALSE);
foreach ($es as $e) {
  if ($e instanceof \Drupal\shusy_store_order\Entity\ShusyStoreOrder) {
    $e->delete();
  }
}

db_truncate('points')->execute();
db_truncate('points_total')->execute();

$es = points_load_multiple(FALSE);
foreach ($es as $e) {
  if ($e instanceof \Drupal\points\Entity\Points) {
    $e->delete();
  }
}


$es = shusy_sweepstake_log_load_multiple(FALSE);
foreach ($es as $e) {
  if ($e instanceof \Drupal\shusy_sweepstake\Entity\ShusySweepstakeLog) {
    $e->delete();
  }
}

$d = distribution_load(94);
if ($d instanceof \Drupal\distribution\Entity\Distribution) {
  $d->tid = 324;
  $d->save();
}


$d = \Drupal\distribution\Entity\Distribution::getDistribution(620);
$d->tid = 623;
$d->pid = 676;
$d->save();


youji_income_order_rules_action_order_period(shusy_store_order_load(3863));

points_to_uid(1248, 'dev', 'gold', mt_rand(10, 1000));

$ids = [158991, 158992];
foreach ($ids as $id) {
  $e = shusy_store_performance_load($id);
  if ($e instanceof \Drupal\shusy_store_performance\Entity\ShusyStorePerformance) {
    unset($e->id);
    $e->save();
  }
}
